﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>StatusBarWait - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The StatusBarWait function waits until a window's status bar contains the specified string." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>StatusBarWait</h1>

<p>Waits until a window's status bar contains the specified string.</p>

<pre class="Syntax"><span class="func">StatusBarWait</span> <span class="optional">BarText, Timeout, Part#, WinTitle, WinText, Interval, ExcludeTitle, ExcludeText</span></pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>BarText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>The text or partial text for the which the function will wait to appear. Default is blank (empty), which means to wait for the status bar to become blank. The text is case sensitive and the matching behavior is determined by <a href="SetTitleMatchMode.htm">SetTitleMatchMode</a>, similar to <em>WinTitle</em> below.</p>
    <p>To instead wait for the bar's text to <em>change</em>, either use <a href="StatusBarGetText.htm">StatusBarGetText</a> in a loop, or use the RegEx example at the bottom of this page.</p>
  </dd>
  
  <dt>Timeout</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a>或<a href="../Concepts.htm#numbers">浮点数</a></p>
    <p>The number of seconds (can contain a decimal point) to wait before timing out, in which case <a href="../misc/ErrorLevel.htm">ErrorLevel</a> will be set to 1. Default is blank, which means the function will wait indefinitely. Specifying 0 is the same as specifying 0.5.</p>
  </dd>
  
  <dt>Part#</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
    <p>Which part number of the bar to retrieve. Default 1, which is usually the part that contains the text of interest.</p>
  </dd>

  <dt>WinTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>, <a href="../Concepts.htm#numbers">整数</a>或<a href="../Objects.htm">对象</a></p>
    <p>识别目标窗口的窗口标题或其他条件. 请参阅 <a href="../misc/WinTitle.htm">WinTitle</a>.</p>
  </dd>

  <dt>WinText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>如果存在, 此参数必须是目标窗口的单个文本元素的子字符串(和内置的 Window Spy 工具显示的一样). 如果 <a href="DetectHiddenText.htm">DetectHiddenText</a> 为 ON, 那么会检测隐藏文本元素.</p>
  </dd>

  <dt>Interval</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
    <p>How often the status bar should be checked while the function is waiting (in milliseconds). Default is 50. </p>
  </dd>

  <dt>ExcludeTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>标题中含有此参数值的窗口将被排除.</p>
  </dd>

  <dt>ExcludeText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>文本中含有此参数值的窗口将被排除.</p>
  </dd>

</dl>

<h2 id="Error_Handling">错误处理</h2>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if the function times out before a match could be found in the status bar. It is set to 2 if the status bar could not be accessed. It is set to 0 if a match is found.</p>
<h2 id="Remarks">备注</h2>
<p>StatusBarWait attempts to read the first <em>standard</em> status bar on a window (class msctls_statusbar32). Some programs use their own status bars or special versions of the MS common control. Such bars are not supported.</p>
<p>Rather than using <a href="StatusBarGetText.htm">StatusBarGetText</a> in a loop, it is usually more efficient to use StatusBarWait because it contains optimizations that avoid the overhead that repeated calls to <a href="StatusBarGetText.htm">StatusBarGetText</a> would incur.</p>
<p>StatusBarWait determines its target window before it begins waiting for a match. If that target window is closed, the function will stop waiting even if there is another window matching the specified <em>WinTitle</em> and <em>WinText</em>.</p>
<p>当函数处于等待状态时, 可以通过<a href="../Hotkeys.htm">热键</a>, <a href="../objects/Menu.htm">自定义菜单项</a>或<a href="SetTimer.htm">计时器</a>启动新的<a href="../misc/Threads.htm">线程</a>.</p>
<p>窗口标题和文本是区分大小写的. 除非 <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> 被打开, 否则不会检测隐藏窗口.</p>

<h2 id="Related">相关</h2>
<p><a href="StatusBarGetText.htm">StatusBarGetText</a>, <a href="WinGetTitle.htm">WinGetTitle</a>, <a href="WinGetText.htm">WinGetText</a>, <a href="ControlGetText.htm">ControlGetText</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExSearch">
<p><a href="#ExSearch">#1</a>: The following example enters a new search pattern into an existing Explorer/Search window.</p>
<pre>if WinExist("Search Results") <em>; Sets the Last Found window to simplify the below.</em>
{
    WinActivate
    Send "{tab 2}!o*.txt{enter}"  <em>; In the Search window, enter the pattern to search for.</em>
    Sleep 400  <em>; Give the status bar time to change to &quot;Searching&quot;.</em>
    StatusBarWait "found", 30
    if ErrorLevel
        MsgBox "The function timed out or there was a problem."
    else
        MsgBox "The search successfully completed."
}</pre>
</div>

<div class="ex" id="ExChange">
<p><a href="#ExChange">#2</a>: The following example waits for the status bar of the active window to <strong>change</strong>.</p>
<pre>SetTitleMatchMode "RegEx"  <em>; Accept <a href="SetTitleMatchMode.htm#RegEx">regular expressions</a> for use below.</em>
if WinExist("A")  <em>; Set the last-found window to be the active window (for use below).</em>
{
    <span class="red">OrigText</span> := StatusBarGetText()
    StatusBarWait "^(?!^\Q" <span class="red">OrigText</span> "\E$)"  <em>; This regular expression waits for any change to the text.</em>
}</pre>
</div>

</body>
</html>